<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

abstract class AbstractController extends CI_Controller {
    
    /**
     * AbstractController::_remap()
     * 
     * Remap the name of controller methode. The name of all action should be prefixed by Action
     * 
     * @param mixed $method the default method name
     * @param mixed $params the parameters
     * @return 
     */
    public function _remap($method, $params = array())
    {
        $method = $method.'Action';
        if (method_exists($this, $method))
        {
            $this->preProcess();
            $result = call_user_func_array(array($this, $method), $params);
            $this->postProcess();
            return $result;
        }
        show_404();
    }

	/**
	 * AbstractController::preProcess()
     * 
     * Executed before any action
	 * 
	 * @return void
	 */
	public function preProcess() {}
    
	/**
	 * AbstractController::postProcess()
     * 
     * Executed after any action
	 * 
	 * @return void
	 */
	public function postProcess() {}
}

